package com.idc.vo;

import com.baomidou.mybatisplus.annotation.TableId;
import com.idc.entity.SysPermissionEntity;
import lombok.Data;
import lombok.ToString;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

@Data
@ToString
public class SpringSysUser implements UserDetails {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * 主键id
	 */
	@TableId
	private String id;
	/**
	 * 部门id
	 */
	private String deptId;
	/**
	 * 部门名
	 */
	private String deptName;
	/**
	 * 用户中文名
	 */
	private String nickName;
	/**
	 * 用户邮箱
	 */
	private String email;
	/**
	 * 用户电话号码
	 */
	private String phone;
	/**
	 * 用户密码
	 */
	private String password;
	/**
	 * 用户登陆名
	 */
	private String username;
	/**
	 * 用户登陆名
	 */
	private Boolean enabled;
	/**
	 * 
	 */
	private Boolean accountNonExpired;
	/**
	 * 
	 */
	private Boolean accountNonLocked;
	/**
	 * 
	 */
	private Boolean credentialsNonExpired;

	private Set<GrantedAuthority> authorities;

	private Set<SysPermissionEntity> permissions = new HashSet<>();

	@Override
	public Collection<? extends GrantedAuthority> getAuthorities() {

		return this.authorities;
	}

	@Override
	public String getPassword() {
		return this.password;
	}

	@Override
	public String getUsername() {
		return this.username;
	}

	@Override
	public boolean isAccountNonExpired() {
		return this.accountNonExpired;
	}

	@Override
	public boolean isAccountNonLocked() {
		return this.accountNonLocked;
	}

	@Override
	public boolean isCredentialsNonExpired() {
		return this.credentialsNonExpired;
	}

	@Override
	public boolean isEnabled() {
		return this.enabled;
	}

}
